package graphics.raytracing;

import graphics.datastructures.Model;

import java.util.ArrayList;
import java.util.Collection;

public class RayTracer {
	int _xmax;
	int _ymax;
	Model _model;
	CameraPosition camera;
	Window window;
	public RayTracer(Model model,Window window,CameraPosition camera)
	{
		_model =model;
		_xmax=window.xy()[0];
		_ymax=window.xy()[1];
		this.camera=camera;
		this.window=window;
	}
	
	
	public void setCamera(CameraPosition pos)
	{
		camera=pos;
	}
	public void traceRays () throws InterruptedException
	{
		window.reset();
		RayRunner runner = new RayRunner();
		for(int i =0;i<_xmax;i++)
			for(int j = 0; j<_ymax;j++)
				window.determineRay(i, j).setRunner(runner).makeRay(_model, window);
			
		runner.boom();
		window.waitForSet();
	}
}
